home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / c / ExtrasLib.lha / ExtrasLib / Source / ArgYN.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-30  |  1.6 KB  |  70 lines

  1. #include <exec/types.h>
  2. #include <clib/alib_protos.h>
  3.  
  4. /****** extras.lib/ArgYesNo ******************************************
  5. *
  6. *   NAME
  7. *       ArgYesNo - Get a boolean tooltype value.
  8. *
  9. *   SYNOPSIS
  10. *       yes = ArgYesNo(TTypes,Entry,DefVal)
  11. *
  12. *       BOOL ArgYesNo(UBYTE **, STRPTR, DefVal);
  13. *
  14. *   FUNCTION
  15. *       This function returns the value of a boolean tooltype.
  16. *
  17. *   INPUTS
  18. *       TTypes - a ToolTypes array returned by ArgArrayInit()
  19. *       Entry - the entry to search for.
  20. *       DefVal - the default boolean value.
  21. *
  22. *   RESULT
  23. *       This function only considers the first letter of the
  24. *       of the value for the tooltype.  If the first letter
  25. *       of the value for the tooltype is 'Y' 'y' 'T' or 't'
  26. *       then this function returns 1, if the function finds
  27. *       'N' 'n' 'F' or 'f' then it returns 0, if this function
  28. *       finds any other character or cannot find the tooltype,
  29. *       then the function returns the DefVal.
  30. *
  31. *   NOTES
  32. *       must link with amiga.lib
  33. *
  34. *   SEE ALSO
  35. *     amiga.lib/ArgArrayInit(), amiga.lib/ArgString(),
  36. *     amiga.lib/ArgInt(), amiga.lib/ArgArrayDone()
  37. ******************************************************************************
  38. *
  39. */
  40.  
  41. BOOL ArgYesNo(UBYTE **TTypes, STRPTR Entry,BOOL DefVal)
  42. {
  43.   BOOL retval;
  44.   UBYTE *s;
  45.   UBYTE *def;
  46.         
  47.   retval=DefVal;
  48.   
  49.   if(s=ArgString(TTypes,Entry,0))
  50.   {
  51.     switch(*s)
  52.     {
  53.       case 'Y':
  54.       case 'y':
  55.       case 'T':
  56.       case 't':
  57.         retval=1;
  58.         break;
  59.       case 'N':
  60.       case 'n':
  61.       case 'F':
  62.       case 'f':
  63.         retval=0;
  64.         break;
  65.     }
  66.   }  
  67.   return retval;
  68. }
  69.  
  70.